package com.yocard.yxyd.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.TypedValue;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.webkit.ValueCallback;
import android.widget.LinearLayout;

import com.yocard.yxyd.R;

/**
 * Created on 2019/4/18.
 * 支付对话框
 */
public class InviteFriendsDialog extends Dialog {
    public static final String WE_CHAT ="we_chat";
    public static final String MOMENTS ="moments";
    public static final String QR_CODE ="qr_code";

    LinearLayout llShareWechat;
    LinearLayout llShareMoments;
    private ValueCallback<String> callback;

    public InviteFriendsDialog(@NonNull Context context, ValueCallback<String> callback) {
        super(context, R.style.payDialog);
        this.callback = callback;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setGravity(Gravity.BOTTOM);//设置显示在底部
        WindowManager windowManager = getWindow().getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;//设置Dialog的宽度为屏幕宽度
        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
//        layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,getContext().getResources().getDisplayMetrics());
        getWindow().setAttributes(layoutParams);

        setContentView(R.layout.dialog_invite_friends);
        findViewById(R.id.ll_share_wechat).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callback.onReceiveValue(WE_CHAT);
                dismiss();
            }
        });
        findViewById(R.id.ll_share_moments).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callback.onReceiveValue(MOMENTS);
                dismiss();
            }
        });
        findViewById(R.id.ll_share_qrcode).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callback.onReceiveValue(QR_CODE);
                dismiss();
            }
        });
        setCanceledOnTouchOutside(true);
    }

//    public void setUpdateListener(ValueCallback<String> callback) {
//        this.callback = callback;
//    }
}
